package service.configuration.xstream.converter;

import service.configuration.xstream.OwnerAssociationConfig;

import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;

public class OwnerConverter implements Converter {

	
	@Override
	@SuppressWarnings("rawtypes")
	public boolean canConvert(Class clazz) {
		return clazz.equals(OwnerAssociationConfig.class);
	}

	@Override
	public void marshal(Object o, HierarchicalStreamWriter h,
			MarshallingContext m) {
	}

	@Override
	public Object unmarshal(HierarchicalStreamReader reader,
			UnmarshallingContext context) {
		OwnerAssociationConfig o = new OwnerAssociationConfig();
		o.setTo(reader.getAttribute("to"));
		o.setQuery(reader.getValue());
		return o;
	}

}
